<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>user page</title>

<link href="../../public/css/jquery.treeTable.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../public/js/jquery.js"></script> 
<script type="text/javascript" src="../../public/js/jquery.treeTable.js"></script>
<script type="text/javascript">
   $(document).ready(function(){
       
         var groupID=$("select#group").val();
                  
                   $.get('http://localhost/Zend_xsis/public/rep/get-route/saleGroupID/'+groupID)
                        .success(function (data){
                   //reload data on <div>
                   $('#route').html(data);
                });
                
                var routeID=$("select#route").val();
             
                 $.get('http://localhost/Zend_xsis/public/rep/get-shop/saleRouteID/'+routeID)
                        .success(function (data){
                           $("#shop").html(data);
                        });
                        
            $("select#group").change(function(){
                    var groupID=$("select#group").val();
                    var type=$(".target").val();
                    
                    $.get('http://localhost/Zend_xsis/public/rep/get-route/saleGroupID/'+groupID)
                        .success(function (data){
                             //reload data on <div>
                             $('#route').html(data);
                        });
                 if(type=='Group'){
                     
                     $.get('http://localhost/Zend_xsis/public/rep/get-history-late-fine/saleGroupID/'+groupID)
                        .success(function (data){
                           $("#history_late").html(data);
                        });
                      $.get('http://localhost/Zend_xsis/public/rep/get-history-visit/saleGroupID/'+groupID)
                        .success(function (data){
                           $("#history_visit").html(data);
                        });
                    
                       
       
                 }
                  
            });
              $("div#route").change(function(){
                    var routeID=$("select#route").val();
                    var type=$(".target").val();
                   
                   $.get('http://localhost/Zend_xsis/public/rep/get-shop/saleRouteID/'+routeID)
                        .success(function (data){
                           $("#shop").html(data);
                        });
                 if(type=='Route'){
                     
                     $.get('http://localhost/Zend_xsis/public/rep/get-history-late-fine/saleRouteID/'+routeID)
                        .success(function (data){
                           $("#history_late").html(data);
                        });
                      $.get('http://localhost/Zend_xsis/public/rep/get-history-visit/saleRouteID/'+routeID)
                        .success(function (data){
                           $("#history_visit").html(data);
                        });
                    
                       
       
                 }
                  
            });
             
             $(".target").change(function(){
                    var groupID=$("select#group").val();
                    var routeid = $("select#route").val();
                    var type=$(".target").val();
                    
                   
                 if(type=='Group'){
                     
                     $.get('http://localhost/Zend_xsis/public/rep/get-history-late-fine/saleGroupID/'+groupID)
                        .success(function (data){
                           $("#history_late").html(data);
                        });
                      $.get('http://localhost/Zend_xsis/public/rep/get-history-visit/saleGroupID/'+groupID)
                        .success(function (data){
                           $("#history_visit").html(data);
                        });
                    
                       $("select#route").attr("disabled","disabled");
       
                 }
                 if(type=='Route'){
                     
                     $.get('http://localhost/Zend_xsis/public/rep/get-history-late-fine/saleRouteID/'+routeid)
                        .success(function (data){
                           $("#history_late").html(data);
                        });
                      $.get('http://localhost/Zend_xsis/public/rep/get-history-visit/saleRouteID/'+routeid)
                        .success(function (data){
                           $("#history_visit").html(data);
                        });
                    
                       $("select#route").removeAttr("disabled","disabled");
       
                 }
                  
            });
   

    });
</script>
</head>
  
    <body>
        <form id="frmHistory" >
        <?php $group=$this->group; 
              $route=$this->route;
              $rep=$this->rep;
        ?>
        <div id="group">
            <select id="group" class="cboGroup" name="cboGroup">
                <?php for($i=0;$i<count($group);$i++){ ?>
                <option value="<?php echo $group[$i]['saleGroupID']; ?>"><?php echo $group[$i]['Desc']; ?></option>
                <?php }?>
            </select>
           
            <select class="target">
                <option value="All" selected="selected">All</option>
                <option value="Group">Group</option>
                <option value="Route">Route</option>
            </select>
        </div>
            <div id="route">
                <?php include "get-route.phtml";?>
            </div>
            <div id="shop">
                <?php include "get-shop.phtml";?>
            </div>
            <div id="rep">
                <select id="rep" class="cboRep" name="cboRep">
                    <?php for($i=0;$i<count($rep);$i++){ ?>
                        <option value="<?php echo $rep[$i]['tblRepID']; ?>"><?php echo $rep[$i]['repName']; ?></option>
                    <?php }?>
                </select>
            </div>
            <h1>Late Fines history</h1>
            <div id="history_late">
                <?php include 'get-history-late-fine.phtml'; ?>
            </div>
            <h1>Visit history</h1>
            <div id="history_visit">
                
                <?php include 'get-history-visit.phtml'; ?>
            </div>
            </form>
    </body>
</html>